const { get, post, patch, delete: del } = require('./api.js');

// 获取所有用户地址
const getAllAddress = () => {
  return get('/user-address');
};

// 根据用户ID获取地址列表
const getAddressByUserId = (userId) => {
  return get('/user-address', { userId });
};

// 根据地址ID获取特定地址信息
const getAddressById = (id) => {
  return get(`/user-address/${id}`);
};

// 创建新地址
const createAddress = (addressData) => {
  return post('/user-address', addressData);
};

// 更新地址信息
const updateAddress = (id, addressData) => {
  return patch(`/user-address/${id}`, addressData);
};

// 删除地址
const deleteAddress = (id) => {
  return del(`/user-address/${id}`);
};

module.exports = {
  getAllAddress,
  getAddressByUserId,
  getAddressById,
  createAddress,
  updateAddress,
  deleteAddress
};